<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/19
 * Time: 11:13
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Logics\MiniProgramAdmin\SwiperLogic;
use App\Http\Traits\SwiperTrait;
use App\Http\Controllers\BaseController;
class SwiperController extends BaseController
{
    use SwiperTrait;

    /**
     * @SWG\Post(
     *     path="/swiper/list",
     *     tags={"Swiper"},
     *     description="获取轮播图列表",
     *     operationId="getSwiperList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getSwiperList()
    {
        $loginSession = $this->loginSession;
        $data = [
            'loginSession' => $loginSession
        ];
        $response = SwiperLogic::getSwiperList($data);
        if ($response->code){
            return self::response($response->code, $response->message);
        }
        return self::response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/swiper/create",
     *     tags={"Swiper"},
     *     description="创建轮播图",
     *     operationId="createSwiper",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，并且通过loginSession获取合作者信息",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="swiper_list_str",
     *         in="query",
     *         description="轮播图列表字符串",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createSwiper()
    {
        $loginSession = $this->loginSession;
        $swiper_list_str = $this->swiper_list_str;
        $data = [
            'loginSession' => $loginSession,
            'swiper_list_str' => $swiper_list_str
        ];
        $response = SwiperLogic::createSwiper($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/swiper/sort",
     *     tags={"Swiper"},
     *     description="轮播图排序",
     *     operationId="sortSwiper",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，并且通过loginSession获取合作者信息",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="swiper_id_str",
     *         in="query",
     *         description="轮播图ID列表字符串",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function sortSwiper()
    {
        $swiper_id_str = $this->swiper_id_str;
        $data = [
            'swiper_id_str' => $swiper_id_str
        ];
        $response = SwiperLogic::sortSwiper($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/swiper/delete",
     *     tags={"Swiper"},
     *     description="deleteSwiper",
     *     operationId="sortSwiper",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥，并且通过loginSession获取合作者信息",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="swiper_id",
     *         in="query",
     *         description="轮播图ID",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function deleteSwiper()
    {
        $swiper_id = $this->swiper_id;
        $data = [
            'swiper_id' => $swiper_id
        ];
        $response = SwiperLogic::deleteSwiper($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}